package functionalEnrichment.semanticSimilarity.semanticSimilarityCalculator.units;

/**
 * This enum gives the details of the three GO Ontologies:
 * Molecular Function, Biological Process and Cellular component. The key
 * piece of information that is stored is the integer accession that corresponds to the root term of
 * the ontology.
 * @author Jamie MacPherson
 */
public enum OntologyType {

    MOLECULAR_FUNCTION("F", 3674),
    CELLULAR_COMPONENT("C", 5575),
    BIOLOGICAL_PROCESS("P", 8150);

    // a short tag to be used to reference the ontology
    private final String tag;

    // the accession (minuse the non-numerocal prefix "GO:") of the root term for that ontology
    private int accession;

    /**
     * @param tag a short tag used to reference the OntologyType
     * @param accession the GO term accession (minuse the non-numerocal prefix "GO:") for the root term of the GO ontology.
     */
    private OntologyType(String tag, int accession) {
        this.tag = tag;
        this.accession = accession;
    }

    /**
     * Get the short tag
     * @return
     */
    public String getTag() {
        return tag;
    }

    /**
     * @return the accession (minuse the non-numerocal prefix "GO:") for the root term of the GO ontology.
     */
    public int getAccession() {
        return accession;
    }

    /**
     * Returns the OntologyType that corresponds to the given String tag
     * @param tag the tag to be compared to the tags of OntologyType objects
     * @return an OntologyType with an equivalent tag.
     * @throws IllegalArgumentException if no OntologyType has the given tag.
     */
    public static OntologyType getOntologyFromTag(String tag) throws IllegalArgumentException{
        
        for( OntologyType goOntology :  OntologyType.values()){
            if(goOntology.getTag().equals(tag)){
                return goOntology;
            }
        }
        throw new IllegalArgumentException("There is no ontology with the tag: " + tag + " please enter one of F, C or P");
        
    }

}
